﻿using KPIS.GERP.Models;
using KPIS.GERP.Models.Class;
using KPIS.GERP.Models.HRM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace KPIS.GERP.WCF.GHRMS
{
    [ServiceContract]
    public interface INamePrefixService
    {
        [OperationContract]
        IEnumerable<MasNamePrefix> Select(MasNamePrefix filter);
    }

    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "NamePrefixService" in code, svc and config file together.
	// NOTE: In order to launch WCF Test Client for testing this service, please select NamePrefixService.svc or NamePrefixService.svc.cs at the Solution Explorer and start debugging.
	[ServiceErrorBehavior(typeof(ElmahErrorHandler))]
    public class NamePrefixService : INamePrefixService
    {
        public IEnumerable<MasNamePrefix> Select(MasNamePrefix filter)
        {
            IEnumerable<MasNamePrefix> model = null;

            using (var db = new GERPContext())
            {
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;

                object[] param;
                model = db.MasNamePrefixs.Where(Utility.GenerateWhereString(filter, out param)).ToList();
            }

            return model;
        }
    }
}
